import unittest
from api.employee import EmployeeApi
from utils import common_assert


class TestEmployee(unittest.TestCase):
    employee_id = None
    # employee_id = "1393034582076547072"

    def setUp(self):
        self.employee_api = EmployeeApi()

    def test01_employee_add(self):
        add_data = {
            "username": "a2021500",
            "mobile": "13002222219",
            "timeOfEntry": "2021-05-14",
            "formOfEmployment": 1,
            "workNumber": "1000000",
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2021-07-30T16:00:00.000Z"
        }

        response = self.employee_api.employee_add(add_data)

        TestEmployee.employee_id = response.json().get("data").get("id")
        print(response.json())
        print(TestEmployee.employee_id)
        common_assert(self, response)

    def test02_employee_update(self):
        add_data = {
            "username": "b2021515",
        }

        response = self.employee_api.employee_update(TestEmployee.employee_id, add_data)
        print(TestEmployee.employee_id)
        print(response.json())
        common_assert(self, response)

    def test03_employee_get(self):
        response = self.employee_api.employee_get(TestEmployee.employee_id)
        print(response.json())
        common_assert(self, response)

    def test04_employee_delete(self):
        response = self.employee_api.employee_delete(TestEmployee.employee_id)
        print(response.json())
        common_assert(self, response)

